<?php

namespace app\admin\controller\ykjp\information\basisinfo;

use app\common\controller\Backend;
use app\admin\model\ykjp\information\basisinfo\Warehouse;

/**
 * 仓库分区
 *
 * @icon fa fa-circle-o
 */
class Partition extends Backend {

    /**
     * Partition模型对象
     * @var \app\admin\model\ykjp\information\basisinfo\Partition
     */
    protected $model = null;
    protected $distinguish = true;

    public function _initialize() {
        parent::_initialize();
        $this->model = new \app\admin\model\ykjp\information\basisinfo\Partition;
    }

    /**
     * 获取仓库列表
     */
    public function getsalesman() {
        $result = array("rows" => [], "total" => 0);
        if ($this->request->isAjax()) {
//            $this->model=new Warehouse();
//           return parent::selectpage();
            if ($this->request->request("keyValue")) {
                $id = $this->request->request("keyValue");
                $warehouse = new Warehouse();
                $list = $warehouse
                        ->field("id,name")
                        ->where("firmid", $this->auth->firmid)
                        ->where("id", $id)
                        ->select();
                return ['total' => 1, 'list' => $list];
            }
            $warehouse = new Warehouse();
            $list = $warehouse
                    ->field("id,name")
                    ->where("firmid", $this->auth->firmid)
                    ->select();
            $count = $warehouse
                    ->field("id,name")
                    ->where("firmid", $this->auth->firmid)
                    ->count();
            $result = array("rows" => $list, "total" => $count);
            return json($result);
        }
        return json($result);
    }

}
